<template>
  <div class="rights-container">
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片盒子 -->
    <el-card class="box-card">
      <el-table :data="rightsList" highlight-current-row style="width: 80%">
        <el-table-column type="index" label="#" width="50"> </el-table-column>
        <el-table-column property="authName" label="权限名称"> </el-table-column>
        <el-table-column property="path" label="路径"> </el-table-column>
        <el-table-column property="level" label="等级">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level == 0">等级一</el-tag>
            <el-tag type="success" v-if="scope.row.level == 1">等级二</el-tag>
            <el-tag type="warning" v-if="scope.row.level == 2">等级三</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  name: 'Rights',
  data() {
    return {
      rightsList: []
    }
  },
  created() {
    // 获取所有权限列表
    this.getRightsList()
  },
  methods: {
    async getRightsList() {
      const { data: res } = await this.$http.get('rights/list')
      // console.log(res)
      if (res.meta.status !== 200) {
        this.$message.error(res.meta.msg)
      }

      this.rightsList = res.data
    }
  }
}
</script>

<style lang="less" scoped></style>
